<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <table>
        <tr>
            <td>ProductName:</td>
            <td><input type="text" placeholder="请输入商品名称" id="name"></td>
        </tr>
        <tr>
            <td>Price:</td>
            <td><input type="text" placeholder="请输入商品价格" id="price"></td>
        </tr>
        <tr>
            <td><input type="button" value="保存" onclick="Save()"></td>
            <td><input type="button" value="取消并返回" onclick="Back()"></td>
        </tr>
    </table>

    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="./js/fn.js"></script>
    <script>
        $(function () {
            let id = window.location.search.split('=')[1] || '';
            if (id) {
                $.get('http://localhost:8080/product', function (res) {
                    res.forEach(item => {
                        if (item.id == id) {
                            $('[id = name]').val(item.productname);
                            $('[id = price]').val(item.price);
                        }
                    });
                })
            }
        })
    </script>
</body>

</html>